package com.jiandan.business.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jiandan.business.entity.Cemetery;
import com.jiandan.business.entity.CemeteryArea;
import com.jiandan.business.entity.CemeteryAreaRow;
import com.jiandan.business.repository.CemeteryAreaDao;
import com.jiandan.business.vo.CemeteryAreaVo;
import com.jiandan.business.vo.CemeterySimpleVo;


@Service
@Transactional(readOnly=true)
public class CemeteryAreaServiceImpl implements CemeteryAreaService{
	
	@Autowired
	private CemeteryAreaDao areaDao;
	
	/**
	 * 获取墓区信息.
	 *
	 * @param areaId the area id
	 * @return the area detail info
	 */
	public CemeteryAreaVo getAreaDetailInfo(Long areaId){
		CemeteryAreaVo vo = new CemeteryAreaVo();
		List<CemeterySimpleVo> simpleVos = new ArrayList<CemeterySimpleVo>();
		CemeteryArea area = areaDao.findOne(areaId);
		Set<CemeteryAreaRow> rows = area.getRows();
		vo.setRows(new ArrayList<CemeteryAreaRow>(rows));
		Set<Cemetery> cemeteries = area.getCemeteries();
		for (Cemetery cemetery : cemeteries) {
			CemeterySimpleVo simpleVo = new CemeterySimpleVo(cemetery.getId(), cemetery.getName(), cemetery.getStatus());
			simpleVos.add(simpleVo);
		}
		vo.setCemeteries(simpleVos);
		vo.setAreaId(area.getAreaId());
		vo.setName(area.getName());
		return vo;
	}

}
